<TYjs file='jquery-1.11.3.min,utils,jquery.ui.min,jquery.placeholder.min,common' public='true'/>
        <TYimport plugin="artDialog"/>
        <TYjs file='common'/>
        <TYcss file='jquery.ui.min' public='true'/>

<link href="__PRIVATE__/css/weui.css" rel="stylesheet">
<script type="text/javascript" src="__PRIVATE__/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="__PRIVATE__/js/datePicker.js"></script>
<!-- 主体内容 -->
<div class="weui-tab__panel">
	<form id="videoOrderForm" enctype="multipart/form-data" method="post">
	<div class="weui-cells">
        <div class="weui-cell weui-cell_select weui-cell_select-after">
            <div class="weui-cell__hd">
                <label for="" class="weui-label">预定项目<span style="color: red;">*</span></label>
            </div>
            <div class="weui-cell__bd">
                <select class="weui-select" name="projectID">
                    <option value="1">宝宝出生视频服务</option>
                </select>
            </div>
        </div>
    </div>
	<div class="weui-cells">
		<div class="weui-cell weui-cell_select weui-cell_select-after">
	         <div class="weui-cell__hd"><label class="weui-label">预约城市<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	        	<select class="weui-select selectProvince" name="provinceID">
                    <option value="">--请选择--</option>
	        		<foreach name="province" item="so" >
						<option value="{$so.provinceid}">{$so.provincename}</option>
					</foreach>
                </select>
	        </div>
	        <div class="weui-cell__bd">
	        	<select class="weui-select selectCity" name="cityID">
                    <option value="">--请选择--</option>
                    <foreach name="city" item="so" >
						<option value="{$so.cityid}">{$so.cityname}</option>
					</foreach>
	        	</select>
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_select weui-cell_select-after">
	        <div class="weui-cell__hd"><label class="weui-label">所在医院<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	            <select class="weui-select selectHispital" name="hospitalID">
                    <option value="">--请选择--</option>
                </select>
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">住院编号<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	            <input class="weui-input" type="text" name="hospitalNO" placeholder="请输入住院编号" >
	        </div>
	    </div>
	    <div id="datepicker" class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">出生时间</label></div>
	        <div class="weui-cell__bd select_bron_time">
	        	<input type="hidden" id="datetime-picker" name="bron_time" value="">
	        	<span class="select_time"></span>
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">出生体重<br/>（kg）</label></div>
	        <div class="weui-cell__bd">
	            <input class="weui-input" type="text" name="baby_weight" placeholder="请输入出生体重" value="">
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">出生身高<br/>（cm）</label></div>
	        <div class="weui-cell__bd">
	            <input class="weui-input" type="text" name="baby_height" placeholder="请输入出生身高" value="" >
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">联系人<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	            <input class="weui-input" type="text" name="parents_name" placeholder="请输入联系人" >
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">联系手机<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	            <input class="weui-input" type="tel" name="parents_phone" pattern="/^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$/" required  placeholder="请输入手机号">
	        </div>
	    </div>
	    <div class="weui-cell weui-cell_access">
	        <div class="weui-cell__hd"><label class="weui-label">视频上传<span style="color: red;">*</span></label></div>
	        <div class="weui-cell__bd">
	        	<input type="file" name="upload_babyvideo[]" multiple="">
                <label class="tips"></label>
	        </div>
	    </div>
	</div>


	<!-- 立即提交 -->
	<div class="weui-btn-area">
	    <a href="javascript:;" class="weui-btn weui-btn_primary comfirm save_btn" onclick="save_upload()">上传</a>
	    <img class="img_tips" style="display: none;" src="__PRIVATE__/Images/indicator.gif" alt="上传中..."><span class="img_tips" style="display: none;">数据上传中，请稍后！！</span>
	</div>
	<!-- 立即提交 -->
	</form>
</div>
<!-- 主体内容 -->

<script type="text/javascript">

$(document).ready(function(){
	$('title').html('初生视频预定');
	$('.selectProvince').change(function(){
		var cityHtml = "<option value=\"\">--请选择--</option>";
		var p_id = $(this).val();
		<foreach name="city" item="c">
			if(p_id == {$c.provinceid}){
				cityHtml += "<option value=\""+{$c.cityid}+"\">{$c.cityname}</option>";
			}
		</foreach>
		$(".selectCity").html(cityHtml);
	});

	$('.selectCity').change(function(){
		var hospitalHtml = "<option value=\"\">--请选择--</option>";
		var c_id = $(this).val();
		<foreach name="hospital" item="h">
			if(c_id == {$h.city_id}){
				hospitalHtml += "<option value=\""+{$h.id}+"\">{$h.hospital_name}</option>";
			}
		</foreach>
		$(".selectHispital").html(hospitalHtml);
	});

	$('.select_bron_time').css('text-align','right');
	var date = new Date();
	var calendar = new datePicker();
	calendar.init({
	    'trigger': '#datepicker', /*按钮选择器，用于触发弹出插件*/
	    'type': 'datetime',/*模式：date日期；datetime日期时间；time时间；ym年月；*/
	    'minDate':date.toLocaleDateString(),/*最小日期*/
	    'onSubmit':function(){
	       var theSelectData=calendar.value;
           $('.select_time').html(theSelectData);
           $('input[name=bron_time]').val(theSelectData);
        },
        onClose:function(){}
	});

});
</script>

<script type="text/javascript">

function checkNumber(){
	var mobilevalid = /^(0|86|17951)?(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/;
	var str = $('input[name=parents_phone]').val();
	if(mobilevalid.test(str)){
        return true;
    }
    else{
        return false;
    }
}

function beforeSend(){
	if( $('input[name=parents_name]').val()=='' ){ /*備註必填*/
		callBackTips(0,'请填写联系人');
		return false;
	}else if( $('input[name=parents_phone]').val()=='' || !checkNumber() ){ /*備註必填*/
		callBackTips(0,'请填写正确联系号码');
		return false;
	}else if( $('input[name=hospitalNO]').val()=='' ){ /*備註必填*/
		callBackTips(0,'请填写住院编号');
		return false;
	}else if( $("input[type=file]").val() =='' ){
		callBackTips(0,'请选择视频文件');
		return false;
	}
    $('.img_tips').show();
    $('.save_btn').hide();
    var sData = {'yu':1};
    $.ajax({
         url: "{:U(MODULE_NAME.'/Hospital/empty_function')}" ,  /*这是处理文件上传的servlet*/
         type: 'POST',
         processData: false,
         data : sData,
         success: function (returndata) {
             if(returndata.status == 1){
                save_upload();
             }
         },
    });
}
function save_upload(){
    var formData = new FormData($( "#videoOrderForm" )[0]);
    $.ajax({
         url: "{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/saveVideoOrder')}" ,  /*这是处理文件上传的servlet*/
         type: 'POST',
         async: false,
         cache: false,
         contentType: false,
         processData: false,
         data : formData,
         success: function (returndata) {
             if(returndata.status == 1){
                $('.img_tips').hide();
                callBackTips(returndata.status, returndata.info,returndata.url);
             }else{
             	$("input[type=file]").val(''); //清空文件
                $('.img_tips').hide();         //隐藏提示
                $('.save_btn').show();		   //显示上传按钮
                callBackTips(returndata.status, returndata.info);
             }
         },
    });
}
</script>


